home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Grafik / AmiCAD / ARexx / Cartouche.amiCAD < prev    next >
Text File  |  1998-06-17  |  4KB  |  156 lines

  1. /* Script ARexx permettant le tracé d'un cartouche dans une fenêtre AmiCAD */
  2. /* Chez Corbin, Vendredi 3 Octobre 1997, Version 1.00, © R.Florac */
  3. /* Version 1.01, 2 Novembre 1997, trait vertical rajouté dans cartouche */
  4. /* Version 1.02, 23 janvier 1998, ajout titre, date, etc... */
  5. /* Version 1.03, 12 février 1998, test longueurs chaînes pour ajustement largeur */
  6. /* Version 1.04, 24 mai 1998, test présence rexxlocaldates.library */
  7. /* $VER: Cartouche.AmiCAD 1.04 (© R.Florac, 13/04/98) */
  8.  
  9. options results
  10.  
  11. organisation="LYCÉE Bernard PALISSY SAINTES"
  12. signal on error
  13. signal on syntax
  14.  
  15. if (~show('L','rexxlocaldates.library')) then
  16.   call addlib('rexxlocaldates.library',0,-30,0)
  17.  
  18. if (show('L','rexxlocaldates.library')) then do
  19.     Ib = OpenLocale()
  20.     jour = FormatDate(Ib, ,"%A %e %B %Y")
  21. end
  22. else do
  23.     'DATE(1)'; jour=result
  24. end
  25.  
  26. 'WWIDTH(-1)'; l = result; lc = result % 3
  27. 'WHEIGHT(-1)'; h =result
  28. 'ROTATE(0,0):SYMMETRY(0,0)'
  29.  
  30. 'SELECT("Emplacement du cartouche"+CHR(10)+"En haut à gauche"+CHR(10)+"En haut à droite"+CHR(10)+"En haut au centre"+CHR(10)+"En bas au centre"+CHR(10)+"En bas à droite"+CHR(10)+"En bas à gauche")'
  31. c = result
  32.  
  33. 'ASK("Titre du cartouche")'; titre = result
  34. if titre='' then exit
  35.  
  36. if lc<260 then lc=260
  37. 'TXWIDTH("'organisation'")'; lt = result
  38. if lt>lc-10 then lc=lt+10
  39. 'TXWIDTH("'titre'")'; lt = result
  40. if lt>lc-10 then lc=lt+10
  41. dx=(lc+5)%4*3
  42. 'TXWIDTH("'jour'")'; lt = result
  43. if lt>dx-10 then do
  44.     dx=lt+10
  45.     lc=dx%3*4
  46. end
  47.  
  48. select
  49.     when c = 1 then do        /* En haut à gauche */
  50.     x0 = 5
  51.     x1 = lc + 5
  52.     y0 = 5
  53.     y1 = 85
  54.     bh = 0
  55.     bb = 1
  56.     bg = 0
  57.     bd = 1
  58.     end
  59.     when c = 2 then do        /* En haut à droite */
  60.     x0 = l - lc - 5
  61.     x1 = l - 5
  62.     y0 = 5
  63.     y1 = 85
  64.     bh = 0
  65.     bb = 1
  66.     bg = 1
  67.     bd = 0
  68.     end
  69.     when c = 3 then do        /* En haut au centre */
  70.     x0 = l % 2 - lc % 2
  71.     x1 = x0 + lc
  72.     y0 = 5
  73.     y1 = 85
  74.     bh = 0
  75.     bb = 1
  76.     bg = 1
  77.     bd = 1
  78.     end
  79.     when c = 4 then do        /* En bas au centre */
  80.     x0 = l % 2 - lc % 2
  81.     x1 = x0 + lc
  82.     y0 = h - 85
  83.     y1 = h - 5
  84.     bh = 1
  85.     bb = 0
  86.     bg = 1
  87.     bd = 1
  88.     end
  89.     when c = 6 then do        /* En bas à gauche */
  90.     x0 = 5
  91.     x1 = 5 + lc
  92.     y0 = h - 85
  93.     y1 = h - 5
  94.     bh = 1
  95.     bb = 0
  96.     bg = 0
  97.     bd = 1
  98.     end
  99.     when c = 5 then do        /* En bas à droite */
  100.     x0 = l - lc - 5
  101.     x1 = l - 5
  102.     y0 = h - 85
  103.     y1 = h - 5
  104.     bh = 1
  105.     bb = 0
  106.     bg = 1
  107.     bd = 0
  108.     end
  109.     otherwise exit
  110. end
  111.  
  112. /* sauvegarde du contexte, dessin du contour */
  113. 'SAVEALL(-1):DRAWMODE(2):DRAW(5,5,'l-5',5):DRAW('l-5',5,'l-5','h-5')'
  114. 'DRAW('l-5','h-5',5,'h-5'):DRAW(5,'h-5',5,5)'
  115.  
  116. /* Tracé du bord horizontal haut */
  117. if bh > 0 then 'DRAW('x0','y0','x1','y0')'
  118. /* Tracé du bord horizontal bas */
  119. if bb > 0 then 'DRAW('x0','y1','x1','y1')'
  120. /* Tracé du bord vertical gauche */
  121. if bg > 0 then 'DRAW('x0','y0','x0','y1')'
  122. /* Tracé du bord vertical droit */
  123. if bd > 0 then 'DRAW('x1','y0','x1','y1')'
  124. /* Tracé des lignes horizontales intermédiaires */
  125. 'DRAW('x0','y0+20','x1','y0+20')'
  126. 'DRAWMODE(1):DRAW('x0','y0+40','x1','y0+40'):DRAW('x0','y0+60','x1','y0+60')'
  127. /* Tracé de la ligne verticale intermédiaire */
  128. 'DRAW('dx+x0','y0+40','dx+x0','y1')'
  129.  
  130. 'SETSCALE(0,1,1)'
  131. call centrer_texte(organisation,x0,x1,y0+15)
  132. call centrer_texte(titre,x0,x1,y0+35)
  133. call centrer_texte(jour,x0,x0+dx,y0+75)
  134. call centrer_texte("Document Numéro 1/1",x0,x0+dx,y0+55)
  135. call centrer_texte("REV 1",x0+dx,x1,y0+55)
  136. call centrer_texte("AmiCAD",x0+dx,x1,y0+75)
  137.  
  138. exit
  139.  
  140. centrer_texte: procedure
  141.     parse arg texte, xg, xd, y
  142.     'TXWIDTH("'texte'")'; l = result
  143.     l = (xd-xg-l)%2
  144.     'WRITE("'texte'",'xg+l','y')'
  145.     return
  146.  
  147. /* Traitement des erreurs, interruption du programme */
  148. syntax:
  149. erreur=RC
  150. 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  151. exit
  152.  
  153. error:
  154. 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur en ligne 'SIGL'")'
  155. exit
  156.